package com.hspedu.newData.dmsxl.树.二叉树的遍历;

import com.hspedu.newData.dmsxl.ds.Node;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author: yh
 * @description: 
 * @CreateTime: 2025-05-12 
 * @Version: 1.0
 */

public class LC589N叉树的前序遍历 {

    List<Integer> list = new ArrayList<>();

    public List<Integer> preorder(Node root) {

        if (root == null){
            return list;
        }
        list.add(root.val);
        List<Node> children = root.children;
        for (Node child : children) {
            preorder(child);
        }
        return list;
    }
}
